﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLBH.DTO;

namespace Module.Category
{
    public partial class EditCalUnitDlg : Form
    {
        private DVTDTO calUnit;

        public DVTDTO CalUnit
        {
            get { return calUnit; }
            set 
            {
                calUnit = value;
               if (calUnit!=null)
               {
                   textBoxName.Text = calUnit.TenDV;
                   textBoxComment.Text = calUnit.GhiChu;
               }
                calUnit = value; 
            }
        }
        public EditCalUnitDlg()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxName.Text))
            {
                MessageBox.Show("Bạn phải nhập tên Đơn Vị", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            calUnit.GhiChu = textBoxComment.Text;
            calUnit.TenDV = textBoxName.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
